// Initialize your app
// var DEBUG_LOCAL = true;
//var SERVER_PATH = 'json/';
var WEB_CONTEXT_PATH = '';
var SERVER_PATH = WEB_CONTEXT_PATH + '/mobile/';
var SCHEME_SERVER_PATH = '';

var PORTRAIT_PATH = WEB_CONTEXT_PATH+'/CONFIRMIMAGE/headportrait/';
var PAGE_SIZE = 20;
var CURRENT_USER;

var myApp = new Framework7({
    init: false, //Disable App's automatica initialization
    precompileTemplates: true,
    template7Pages: true, // enable Template7 rendering for Ajax and Dynamic pages
    template7Data: {}
});
myApp.splitMultiColumns = function() {};

// Export selectors engine
var $$ = Dom7;

// Add views
var view1 = myApp.addView('#view-home', {
    // Because we use fixed-through navbar we can enable dynamic navbar
    dynamicNavbar: true
});

//$$.getJSONP(SERVER_PATH + 'getHeadportraitPath.do', null, function (json) {
//   if (json.code == 1) {
//        PORTRAIT_PATH = json.results;
//    }
//});

var homePage;
function refreshHome (page) {
    $$.getJSONP(SERVER_PATH + 'menuIndex.do', null, function (json) {
        if (json.code == 1) {
            var ul, html, grid_slides = [];
            $$.each(json.results, function (index, value) {
                if (index % 12 === 0) {
                    if (ul) {
                        grid_slides.push({
                            id: 'grid-' + grid_slides.length,
                            content: ul.prop('outerHTML')
                        });
                    }
                    ul = $$('<ul class="grid-menu">' +
                        '<div class="separator-horizontal" style="position:absolute; top: 25%; left: 0"></div>' +
                        '<div class="separator-horizontal" style="position:absolute; top: 50%; left: 0"></div>' +
                        '<div class="separator-horizontal" style="position:absolute; top: 75%; left: 0"></div>' +
                        '<div class="separator-vertical" style="position:absolute; top: 0; left: 33.333333333333336%; left: -webkit-calc((100% - 1px*2) / 3); left: calc((100% - 1px*2) / 3)"></div>' +
                        '<div class="separator-vertical" style="position:absolute; top: 0; left: 66.666666666666672%; left: -webkit-calc((100% - 1px*2) * 2 / 3); left: calc((100% - 1px*2) * 2 / 3);"></div>' +
                        '</ul>');
                }

                html = '<li ><a class="menu-link" href="' + value.moduleUrl + '">' +
                    '<i class="icon" style="background-image:url(\'' + value.img + '\')">' +
                    (value.unReadCount > 0 ? '<span class="badge">' + (value.unReadCount > 99 ? '99+' : value.unReadCount) + '</span>' : '') + '</i>' +
                    '<span>' + value.moduleName + '</span>' +
                    '</a></li>';
                ul.append(html);
            });
            if (ul) {
                grid_slides.push({
                    id: 'grid-' + grid_slides.length,
                    content: ul.prop('outerHTML')
                });
            }

            var gridPager = $$(page.container).find('.page-content').data('grid-pager');
            if (gridPager) {
                gridPager.close();
            }
            gridPager = myApp.welcomescreen(grid_slides, {
                target: $$(page.container).find('.page-content'),
                cssClass: 'grid-pager',
                closeButton: false
            });
            $$(page.container).find('.page-content').data('grid-pager', gridPager);

        }
    });

    $$.getJSONP(SERVER_PATH + 'quickIndex.do', null, function (json) {
        if (json.code == 1) {
            var count = json.results.length;
            if (count > 5) count = 5;
            var angle = [270, 230, 305, 235, 308];
            var radius = [160, 110, 100, 200, 190];
            $$('#wheel').children('li.item').remove();
            for (var i = 0; i < count; i++) {
                var html = '<li class="item item' + (i + 1) + '" data-angle="' + angle[i] + '" data-radius="' + radius[i] + '">' +
                    '<a href="' + json.results[i].moduleUrl + '"><i class="icon icon-fast-menu" style="background-image: url(\'' + json.results[i].img +'\');"></i>' +
                    '<span>' + json.results[i].moduleName + '</span></a>' +
                    '</li>';
                $$('#wheel').append(html);
            }
        }
    });

    $$.getJSONP(SERVER_PATH + 'UnReadNumOfMessage.do', null, function (json) {
       if (json.code == 1) {
           $$(view1.container).find('.badge-dot')[json.results > 0 ? 'show' : 'hide']();
        }
    });
}

myApp.onPageInit('login', function (page) {
    console.log("onPageInit " + page.name);

    //设置页面主题
    var themeName = localStorage.getItem('themeName');
    if(themeName){
        $('body').attr('data-theme', themeName);
    } else {
        $('body').attr('data-theme', '');
    }

    // login input css
    var inputs = $$('.login-screen input[type=text]').add('.login-screen input[type=password]');
    inputs.parents('.item-inner').css('border-bottom', '1px solid rgba(255, 255, 255, 0.3)');
    inputs.focusin(function () {
        $(this).parents('.item-inner').css('border-bottom', '1px solid #fff');
    }).focusout(function () {
        $(this).parents('.item-inner').css('border-bottom', '1px solid rgba(255, 255, 255, 0.3)');
    });

    var nameInput = $$(page.container).find('input[name="username"]'),
        pwdInput = $$(page.container).find('input[name="password"]'),
        rememberBox = $$(page.container).find('input[name="remember-checkbox"]'),
        autoLoginBox = $$(page.container).find('input[name="autologin-checkbox"]'),
        button = $$(page.container).find('.login-button'),
        logoutbutton = $$('.siderbar .logout-button'),
        transition = $$(page.container).find('.login-screen-transition');

    nameInput.val(localStorage.getItem('username'));
    rememberBox.prop('checked', localStorage.getItem('remember-password') == 'true');
    autoLoginBox.prop('checked', localStorage.getItem('auto-login') == 'true');
    if (rememberBox.prop('checked')) {
        pwdInput.val(localStorage.getItem('password'));
    }

    rememberBox.change(function () {
        var checked = $$(this).prop('checked');
        autoLoginBox.prop('disabled', !checked);
        autoLoginBox.parents('.label-checkbox').css('opacity', checked ? '1' : '0.5');
    }).change();

    nameInput.add(pwdInput).on('input', function () {
        if (nameInput.val() && pwdInput.val()) {
            button.removeClass('disabled');
        } else {
            button.addClass('disabled');
        }
    }).trigger('input');

    function onLoginSuccess(user) {

        CURRENT_USER = user;
        $$.getJSONP(SERVER_PATH + 'getPersonalInfo.do', null, function (json) {
            if (json.code == 1) {
                $$.each(json.results, function (key, value) {
                    CURRENT_USER[key] = value;
                });
                $$('a.icon-user img').attr('src', CURRENT_USER.image);
                $$('.siderbar .avart img').attr('src', CURRENT_USER.image);
                $$('.siderbar .avart .username').text(CURRENT_USER.username);
                $$('.siderbar .avart .loginname').text(CURRENT_USER.loginname);
            }
        });

        if (homePage) {
            refreshHome(homePage);
        }

        transition.show();
        transition.prevAll().hide();

        var width = $$(page.container).width(),
            height = $$(page.container).height(),
            x = (width - transition.outerWidth()) / 2,
            y = (height - transition.outerHeight()) / 2;
        transition.css({
            left: x + 'px',
            top: y + 'px',
            opacity: 0.01
        });
        transition.progress = 0.01;

        var animId;
        function zoomOut() {
            transition.progress += 0.02;
            transition.transform('scale(' + transition.progress + ')');
            transition.css({opacity: transition.progress});
            if (transition.progress < 1) {
                animId = $$.requestAnimationFrame(zoomOut);
            } else {
                myApp.closeModal('.login-screen.modal-in');
            }
        }
        animId = $$.requestAnimationFrame(zoomOut);

    }

    button.on('click', function () {
        var username = nameInput.val(),
            password = pwdInput.val();

        if (username.length == 0) {
            myApp.toast('请输入用户名', '<div>×</div>', {}).show(true);
            return;
        }
        if (password.length == 0) {
            myApp.toast('请输入密码', '<div>×</div>', {}).show(true);
            return;
        }

        localStorage.setItem('username', username);
        localStorage.setItem('remember-password', rememberBox.prop('checked'));
        localStorage.setItem('auto-login', autoLoginBox.prop('checked'));
        if (rememberBox.prop('checked')) {
            localStorage.setItem('password', password);
        } else {
            localStorage.removeItem('password');
        }

        myApp.showIndicator();
        $$.getJSONP(SERVER_PATH + 'mobileLogin.do', {loginname: username, password: password}, function (json) {
            myApp.hideIndicator();
            if (json.code == 1) {
                onLoginSuccess(json.results);
            } else {
                myApp.toast(json.msg, '<div>×</div>', {}).show(true);
            }
        });
    });

    //注销账户
    logoutbutton.on('click', function () {
        console.log("logout");

        localStorage.removeItem('username');
        localStorage.removeItem('password');
        localStorage.removeItem('remember-password');
        localStorage.removeItem('auto-login');
        //CURRENT_USER = null;

        window.location.reload();
        //myApp.mainView.router.refreshPage();
    });
    $$('.siderbar .clear-button').on('click', function () {
        console.log("clear profile");

        localStorage.removeItem('username');
        localStorage.removeItem('password');
        localStorage.removeItem('remember-password');
        localStorage.removeItem('auto-login');
    });

//    var localname = $$.parseUrlQuery(window.location.href).localname;
//    if (localname) {
//        transition.prevAll().hide();
//        myApp.showIndicator();
//        $$.getJSONP(SERVER_PATH + 'mobileLoginForIsh.do', {loginname: localname}, function (json) {
//            myApp.hideIndicator();
//            if (json.code == 1) {
//                logoutbutton.hide();
//                onLoginSuccess(json.results);
//            } else {
//                transition.prevAll().show();
//            }
//        });
//    } else if (autoLoginBox.prop('checked')) {
//        button.click();
//    }

    if(typeof clientType!=="undefined"){
    	logoutbutton.hide();
		localStorage.removeItem('username');
        localStorage.removeItem('password');
        localStorage.removeItem('remember-password');
        localStorage.removeItem('auto-login');
        if(clientType==1){
            document.addEventListener("deviceready", function(){
				TrunPage.getPassword(function(data){
				if(data){
					 TrunPage.getUserName(function(data){
						if (data) {
							transition.prevAll().hide();
							myApp.showIndicator();
							$$.getJSONP(SERVER_PATH + 'mobileLoginForIsh.do', {loginname: data}, function (json) {
								myApp.hideIndicator();
								if (json.code == 1) {
									onLoginSuccess(json.results);
								} else {
									transition.prevAll().show();
								}
							});
						}
					});
				}				
			});
            }, false);
        }else{
        	TrunPage.getPassword(function(data){
			if(data){
	            TrunPage.getUserName(function(data){
	                if (data) {
	                    transition.prevAll().hide();
	                    myApp.showIndicator();
	                    $$.getJSONP(SERVER_PATH + 'mobileLoginForIsh.do', {loginname: data}, function (json) {
	                        myApp.hideIndicator();
	                        if (json.code == 1) {
	                            onLoginSuccess(json.results);
	                        } else {
	                            transition.prevAll().show();
	                        }
	                    });
	                }
	            });
			}
        	});
        }
    }else{
        $$(page.container).find('.login-screen-content').show();
        if(autoLoginBox.prop('checked')){
            button.click();
        }
    }
});

$("#fast-menu").wheelmenu({
    trigger: "click",
    animation: "fade",
    animationSpeed: "fast"
});

myApp.onPageInit('home', function (page) {
    console.log("onPageInit " + page.name);

    homePage = page;
    if (CURRENT_USER) {
        refreshHome(homePage);
    }
});
myApp.onPageAfterAnimation('home', function (page) {
    console.log("onPageAfterAnimation " + page.name);

    if (CURRENT_USER) {
        refreshHome(homePage);
    }
});
myApp.onPageBeforeRemove('home', function (page) {
    var gridPager = $$(page.container).find('.page-content').data('grid-pager');
    if (gridPager) {
        gridPager.close();
    }
});

//动态导航栏刷新头像
$$(document).on('navbarInit', function (e) {
    var navbar = e.detail.navbar;
    var navbarCon = $$(navbar.container);

    if(CURRENT_USER){
        navbarCon.find('.icon-user img').attr('src', CURRENT_USER.image);
    }
});

myApp.init();


function preprocessData(type, value) {
    if (type === 'workItemList') {
        value.portrait = PORTRAIT_PATH + value.senduserid + '.jpg';
        value.taskcreatedate = value.taskcreatedate.substring(0, 16);
    } else if (type === 'userAndJobAllProcessTaskList') {
        value.portrait = PORTRAIT_PATH + value.senduserid + '.jpg';
        value.startdate = value.startdate.substring(0, 16);
    } else if (type === 'docRelayList') {
        value.portrait = PORTRAIT_PATH + value.docRelay.creatorId + '.jpg';
        value.sponsor_time = value.sponsor_time.substring(0, 16);
    } else if (type === 'docRelayDoneList') {
        value.portrait = PORTRAIT_PATH + value.docRelay.creatorId + '.jpg';
        value.oaDocReceiver = value.oaDocReceiver.substring(0, 16);
    } else if (type === 'applicationStatusList') {
        if (value.formid == 'mangoMeetingApply') {//会议
            value.iconClass = 'icon-caption';
        } else if (value.formid == 'topicApply') {//议题
            value.iconClass = 'icon-issue';
        } else if (value.formid == 'topicCollect') {//议题汇总
            value.iconClass = 'icon-allissue';
        } else if (value.formid == 'weekDetailApply') {//周会表
            value.iconClass = 'icon-weeklymeeting';
        } else {//系统表单是数字
            value.iconClass = 'icon-form';
        }

        value.uuid = $$.uniqueName();
        myApp.template7Data[value.uuid] = value;
    } else if (type === 'xxwjList') {
    } else if (type === 'announcementList') {
        value.publishDate = value.publishDate.substring(0, 16);
    } else if (type === 'MessageCenter') {
    }
}
function getDataTemplate(type) {
    var template;
    if (type === 'workItemList') {
        template = Template7.templates.workItemTemplate;
    } else if (type === 'userAndJobAllProcessTaskList') {
        template = Template7.templates.userAndJobAllProcessTaskTemplate;
    } else if (type === 'docRelayList') {
        template = Template7.templates.relayItemTemplate;
    } else if (type === 'docRelayDoneList') {
        template = Template7.templates.relayDoneItemTemplate;
    } else if (type === 'applicationStatusList') {
        template = Template7.templates.applyStatusTemplate;
    } else if (type === 'xxwjList') {
        template = Template7.templates.xxwjTemplate;
    } else if (type === 'announcementList') {
        template = Template7.templates.announcementTemplate;
    } else if (type === 'MessageCenter') {
        template = Template7.templates.messageTemplate;
    }
    return template;
}


// Templates
Template7.templates.workItemTemplate = Template7.compile(
    '<li><a href="workItem-details.html?id={{id}}&wt={{wt}}&weboffice={{weboffice}}" class="item-link item-content">' +
    '<div class="item-media"><img class="icon icon-portrait" src="{{portrait}}"></div>' +
    '<div class="item-inner">' +
    '<div class="item-title-row">' +
    '<div class="item-title">{{#js_compare "this.hjId > 0 && this.hjType != \'General\'"}}<span style="color: #ef8333">！</span>{{/js_compare}}{{processinstancetitle}}</div>' +
    '{{#js_compare "this.unReadWorkItem == 0"}}<div class="item-after"><span class="badge">New</span></div>{{/js_compare}}' +
    '</div>' +
    '<div class="item-title-row"><div class="item-subtitle">【{{processname}}】</div><div class="item-after">{{taskcreatedate}}</div></div>' +
    '</div>' +
    '</a></li>');
Template7.templates.relayItemTemplate = Template7.compile(
    '<li><a href="docRelay-details.html?docRelayId={{docRelay.rootId}}&weboffice={{weboffice}}" class="item-link item-content">' +
    '<div class="item-media"><img class="icon icon-portrait" src="{{portrait}}"></div>' +
    '<div class="item-inner">' +
    '<div class="item-title-row">' +
    '<div class="item-title">{{docRelay.docTitle}}</div>' +
    '{{#js_compare "this.unReadDocrelay == 0"}}<div class="item-after"><span class="badge">New</span></div>{{/js_compare}}' +
    '</div>' +
    '<div class="item-title-row"><div class="item-subtitle">【{{processname}}】</div><div class="item-after">{{sponsor_time}}</div></div>' +
    '</div>' +
    '</a></li>');
Template7.templates.relayDoneItemTemplate = Template7.compile(
    '<li><a href="docRelayDone-details.html?docRelayId={{docRelay.rootId}}&weboffice={{weboffice}}" class="item-link item-content">' +
    '<div class="item-media"><img class="icon icon-portrait" src="{{portrait}}"></div>' +
    '<div class="item-inner">' +
    '<div class="item-title">{{docRelay.docTitle}}</div>' +
    '<div class="item-title-row"><div class="item-subtitle">【{{processname}}】</div><div class="item-after">{{oaDocReceiver}}</div></div>' +
    '</div>' +
    '</a></li>');
Template7.templates.userAndJobAllProcessTaskTemplate = Template7.compile(
    '<li><a href="userAndJobAllProcessTask-details.html?processinstanceid={{processinstanceid}}&weboffice={{weboffice}}" class="item-link item-content">' +
    '<div class="item-media"><img class="icon icon-portrait" src="{{portrait}}"></div>' +
    '<div class="item-inner">' +
    '<div class="item-title">{{processinstancetitle}}</div>' +
     '<div class="item-title-row"><div class="item-subtitle">【{{processname}}】</div><div class="item-after">{{startdate}}</div></div>' +
    '</div>' +
    '</a></li>');

Template7.templates.announcementTemplate = Template7.compile(
    '<li data-id="{{announcementInfos[0].pkId}}"><a href="announcement-details.html?pkId={{announcementInfos[0].pkId}}" class="item-link item-content">' +
    '<div class="item-inner">' +
    '<div class="item-title-row">' +
    '<div class="item-title">{{#if announcementInfos[0].topFlag}}<span class="red">【置顶】</span>{{/if}}{{announcementInfos[0].title}}</div>' +
    '{{#if announcementInfos[0].isRead}}{{else}}<div class="item-after"><span class="badge">New</span></div>{{/if}}' +
    '</div>' +
    '<div class="item-title-row"><div class="item-subtitle">发布人：{{announcementInfos[0].publishUserName}}</div><div class="item-after">{{publishDate}}</div></div>' +
    '</div>' +
    '</a></li>');
Template7.templates.xxwjTemplate = Template7.compile(
    '<li><a href="xxwj-details.html?id={{id}}" class="item-link item-content">' +
    '<div class="item-inner">' +
    '<div class="item-title-row"><div class="item-title">{{title}}{{#if hasAtt}}<i class="icon icon-attachment"></i>{{/if}}</div>{{#if isRead}}{{else}}<div class="item-after"><span class="badge">New</span></div>{{/if}}</div>' +
        //'<div class="item-title-row"><div class="item-subtitle">发件人：{{publishUser}}</div><div class="item-after">发布时间：{{publishDate}}</div></div>' +
    '<div class="item-subtitle">发件人：{{publishUser}}</div><div class="item-after" style="float: right; font-size: 13px;">{{publishDate}}</div>' +
    '</div>' +
    '</a></li>');
Template7.templates.messageTemplate = Template7.compile(
    '<li><a href="#" class="item-link item-content">' +
    '<div class="item-inner">' +
    '<div class="item-title-row">' +
    '<div class="item-title">{{title}}</div>' +
    '{{#js_compare "this.unReadMessage == 0"}}<div class="item-after"><span class="badge">New</span></div>{{/js_compare}}' +
    '</div>' +
    '<div class="item-subtitle" style="text-align: right">{{time}}</div>' +
    '</div>' +
    '</a></li>');

Template7.templates.applyStatusTemplate = Template7.compile(
    '<li><a href="applicationStatus-details.html?uuid={{uuid}}" class="item-link item-content">' +
    '<div class="item-media"><i class="icon {{iconClass}}"></i></div>' +
    '<div class="item-inner">' +
    '<div class="item-title-row"><div class="item-title">{{processinstancetitle}}</div>{{#js_compare "this.applyStatus == 1"}}<div class="item-after status-success"><i class="icon"></i>申请成功</div>{{else}}<div class="item-after status-process">申请中</div>{{/js_compare}}</div>' +
    '<div class="item-subtitle">【{{processname}}】</div>' +
    '{{#if showInfo}}{{#if showInfo[0]}}<div class="item-subtitle">使用时间：{{showInfo[0].beginTime}}{{#if showInfo[0].beginTime}}</div><div class="item-subtitle" style="padding-left: 60px;">～{{/if}}{{showInfo[0].endTime}}</div>' +
    '<div class="item-subtitle">会议室：{{showInfo[0].meetingRoom}}</div>' +
    '<div class="item-subtitle">会议申请人：{{showInfo[0].applicant}}</div>{{/if}}{{/if}}' +
    '</div>' +
    '</a></li>');
Template7.templates.applyConfirmTemplate = Template7.compile(
    '<li class="item-content item-timedot">' +
    '<div class="item-media"><span>{{index}}</span></div>' +
    '<div class="item-inner">' +
    '<div class="item-subtitle">审批时间：{{confirmdate}}</div>' +
    '<div class="item-subtitle">审批人：{{confirmusername}}</div>' +
    '<div class="item-subtitle">审批意见：{{confirminfo}}</div>' +
    '</div>' +
    '</li>');

Template7.templates.fileTemplate = Template7.compile(
    '<li>' +
        '<a href="#" data-type="{{suffix}}" data-name="{{name}}" data-id="{{attachId}}" class="item-content item-link file-link">' +
            '<div class="item-media">' +
                '<i class="icon icon-{{suffix}}"></i>' +
            '</div>' +
            '<div class="item-inner">' +
                '<div class="item-title">{{name}}</div>' +
                '<div class="item-after"><i class="icon {{#if canPreview}}icon-preview{{else}}icon-download{{/if}}"></i></div>' +
            '</div>' +
        '</a>' +
    '</li>');
$$(document).on('click', 'a.file-link', function (e) {
    e.preventDefault();
    console.log('click ' + $$(this).attr('data-id'));
    var name = $$(this).attr('data-name');
    var type = $$(this).attr('data-type');
    var attid = $$(this).attr('data-id');
    var downloadurl = WEB_CONTEXT_PATH + "/downloadattachment/" + attid + "/" + name + "?iPlanetDirectoryPro=" + CURRENT_USER.iPlanetDirectoryPro;
    if(clientType==1){
        document.addEventListener("deviceready", function(){
            name = name.substr(0,name.indexOf("."+type));
            TrunPage.openAttachment(downloadurl,name,type);
        }, false);
    }else{
        name = name.substr(0,name.indexOf("."+type));
        TrunPage.openAttachment(downloadurl,name,type);
    }
});

Template7.templates.agendaTemplate = Template7.compile(
    '<li class="swipeout">' +
        '<a href="#" data-pkId="{{pkId}}" class="item-link swipeout-content item-content">' +
            '<div class="agenda-time">' +
                '<p>{{beginDate}}</p><p>{{endDate}}</p>' +
            '</div>' +
            '<div class="item-inner">' +
                '<div class="item-title line-clamp">{{title}}</div>' +
                '<form class="star-rating-display">' +
                    '<input name="{{id}}" {{#js_compare "this.grade == 1"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
                    '<input name="{{id}}" {{#js_compare "this.grade == 2"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
                    '<input name="{{id}}" {{#js_compare "this.grade == 3"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
                    '<input name="{{id}}" {{#js_compare "this.grade == 4"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
                    '<input name="{{id}}" {{#js_compare "this.grade == 5"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
                '</form>' +
            '</div>' +
        '</a>' +
        '<div class="swipeout-actions-right"><a href="#" class="swipeout-delete">删除</a></div>' +
    '</li>');
Template7.templates.leaderAgendaTemplate = Template7.compile(
    '<li><a href="leaderAgenda-details.html?pkId={{pkId}}" class="item-link item-content">' +
    '<div class="agenda-time">' +
    '<p>{{beginDate}}</p><p>{{endDate}}</p>' +
    '</div>' +
    '<div class="item-inner">' +
    '<div class="item-title line-clamp">{{title}}</div>' +
    '<form class="star-rating-display">' +
    '<input name="{{id}}" {{#js_compare "this.grade == 1"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
    '<input name="{{id}}" {{#js_compare "this.grade == 2"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
    '<input name="{{id}}" {{#js_compare "this.grade == 3"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
    '<input name="{{id}}" {{#js_compare "this.grade == 4"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
    '<input name="{{id}}" {{#js_compare "this.grade == 5"}}checked="checked"{{/js_compare}} type="radio" class="star" disabled readonly/>'+
    '</form>' +
    '</div>' +
    '<div class="agenda-after"><p>{{leadactName}}</p></div>' +
    '</a></li>');
Template7.templates.weekAgendaTemplate = Template7.compile(
    '<li><a href="#" class="item-link item-content">' +
    '<div class="agenda-time">' +
    '<p>{{startTime}}</p><p>{{endTime}}</p>' +
    '</div>' +
    '<div class="item-inner">' +
    '<div class="item-title line-clamp">{{title}}</div>' +
        //'<div class="item-title-row"><div class="item-subtitle">主持人: {{linkMan}}</div><div class="item-after">参加部门: {{mainDepart}}</div></div></div>' +
    '<div class="item-subtitle line-clamp">主持人: {{linkMan}}</div>' +
    '<div class="item-subtitle line-clamp">参加部门: {{mainDepart}}</div>' +
    '</div>' +
    '<div class="agenda-after">' +
        //'<p>会议室</p>' +  //省去“会议室”几个字
    '<p>{{roomName}}</p>' +
    '</div>' +
    '</a></li>');